package com.ktjy.sample.service;

import com.ktjy.sample.dao.PetDao;
import com.ktjy.sample.dao.PetDaoImpl;
import com.ktjy.sample.dao.PetDaoOracleImpl;
import com.ktjy.sample.entity.Pet;
import com.ktjy.sample.factory.PetDaoFactory;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service("petService")
public class PetServiceImpl implements PetService{
//    PetDao petDao=new PetDaoImpl();
//    PetDao petDao= PetDaoFactory.getPetDao(PetDaoFactory.defaultBeanName);
//@Qualifier("petDaoMySql")
//@Autowired
@Resource(type= PetDaoOracleImpl.class)
    private PetDao petDao;

    public PetDao getPetDao() {
        return petDao;
    }

    public void setPetDao(PetDao petDao) {
        this.petDao = petDao;
    }

    @Override
    public boolean save(Pet pet) {
        return petDao.insert(pet)>0;
    }
}
